home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
batch
/
TSBAT35.ARJ
/
PROMPT.TXT
< prev
next >
Wrap
Text File
|
1992-02-21
|
4KB
|
106 lines
This file contains prompt tips by (All rights reserved)
...................................................................
Prof. Timo Salmi
Moderating at garbo.uwasa.fi anonymous ftp archives 128.214.87.1
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun
1) If you have programs that can shell to dos it would be nice to
know whether you currently are in a dos shell or not. Else you might
call the same program again from the shell and eventually run out of
memory. There is a rather straight-forward trick for this. Assume
that your program is called prog.exe. You can always call the
program from a batch, say pro.bat. Include the following lines in
your batch:
set _prompt=%prompt%
set prompt=%_prompt%[in shell or whatever text]
prog %1 %2 %3 %4 %5 %6 %7 %8 %9
set prompt=%_prompt%
set prompt=
The method will not work or will produce unexpected results if the
program itself manipulates the prompt when shelling to Dos. Some
(usually advanced) programs do.
2) A frequently asked question about ansi.sys is now does one use it
to redefine keyboard keys. Here is an example which redefines the F1
key invoke the directory "dir" command, the F2 key to invoke the
"dir/w" command, and the F3 to type the Scandinavian letter ä.
prompt $e[0;59;"dir";13p
prompt $e[0;60;"dir/w";13p
prompt $e[0;61;"ä"p
prompt $p$g
The last line is needed to restore the prompt in its usual format
(which I have as $p$g).
To cancel the definitions apply
prompt $e[0;59;;p
prompt $e[0;60;;p
prompt $e[0;61;;p
prompt $p$g
This system requires that you have ansi.sys loaded in your
config.sys file
device=c:\dos\ansi.sys
Note that ansi.sys replacements like zansi.sys (which I normally use
myself) do not have the key-redefinition feature. This has one
advantages, that is protecting you against the so-called ansi bombs.
The 0;59 pair defines F1 because it is that key's scan code. To get
the scan codes of the different keys you need either a scan code
table or a program that gives the scan code of the key you have
pressed. One such program is garbo.uwasa.fi:/pc/keyboard/keyb21.zip.
3) You can devise quite complicated ansi prompts to do flashy
things although much of this is rather computer entertainment than
serious usage. Let look at some examples
My ordinary prompt is the simple
prompt $p$g
which displays the directory followed bu the > sign. Furthermore I
use bright yellow on black, but for that I apply echo
Let's build from that.
prompt $d $t$_$p$g
Gives the date and the time on the first line ($d $t), then on the
second ($_) gives the current directory ($p) and the > sign ($g).
Lets take a little more complicated example next:
prompt $e[s$e[1;69H$t$h$h$h$e[u$p$g
This is of of the basic prompt tricks, and it puts the time in the
upper right corner of the screen. First the current cursor postion
is stored ($e[s); the cursor is moved to row 1, column 69 ($e[1;69H)
the time is displayed ($t); the hundredths of a second are deleted
($h$h$h); the original cursor position is restored ($e[u); and
finally the current directory and the > sign are displayed ($p$g).
The next obvious step is to display the time in some garish reverse.
For the normal part of the prompt lets use my own default which is
bright yellow on black ($e[40;33;1m).
prompt $e[s$e[1;69H$e[41;32;1m$t$e[40;33;1m$h$h$h$e[u$p$g
The time is displayed in bright green on red ($e[41;32;1m).
The interpretation of the following prompt is left as an exercise:
prompt $e[s$e[H$e[43;30m$e[KDirectory $p $d $t $h$h$h$h $v
$e[40;33;1m$e[2;1H$e[K$e[u$p$g
Note that you must have everything on one line only. The wrap here
is just for readability.
One example of an "entertainment" prompt just to give the general
idea:
prompt $e[s$_$e[40;37m██$e[34m██$e[37m████$_$e[34m████████
$e[40;37m$_██$e[34m██$e[37m████$e[40;33m $p$g
Note that you must have everything on one line only. The wrap here
is just for readability.
4) If you are having prombles you can "debug" your prompt by giving
the set command in MsDos which displays your environment variables
including the prompt variable.